﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DBLibrary;

public partial class masterPages_spend_SpendList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void DeleteImageButton_Click(object sender, ImageClickEventArgs e)
    {
        DB db = PoseidonDBHelper.UserDB;
        for (int i = 0; i <= this.SpendItemGridView.Rows.Count - 1; i++)
        {
            CheckBox cbox = (CheckBox)SpendItemGridView.Rows[i].FindControl("DeleteCheckBox");
            if (cbox.Checked)
            {
                int spendItemId = int.Parse(SpendItemGridView.DataKeys[i].Value.ToString());
                db.Delete<SpendItemDetail>(new DBParam("SpendItemId", spendItemId));
            }
        }
        SpendItemGridView.DataBind();
    }
}